<?php
header('content-type:text/html; charset=utf-8');

?>
<html>
<head>
<title>Bootstrap 模板</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" charset="UTF-8" >
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="css/bootstrap.min.css" rel="stylesheet">
<script src="js/jquery-1.11.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<!--[if lt IE 9]>
<script src="js/html5shiv.js"></script>
<script src="js/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
   		<div class="row">
   			<div class="col-xs-4">
   			<div class="navbar navbar-default">
   			<form class="navbar-form">
			<div class="input-group">
			<input class="form-control" name="text" placeholder="搜索"/>
			<div class="input-group-btn">
			<button type="submit" class="btn btn-default" style="height:34px;">
			<span class="glyphicon glyphicon-search"></span>
			</button>
			</div>
			</div>
		<ul class="nav navbar-nav navbar-right">
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><div class="glyphicon glyphicon-th-list"></div>通讯录<span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="kong1.php">添加</a></li>
            <li><a href="#">列表</a></li>
            </ul>
        </li>
      </ul>
	 	</form>
		</div>
		</div>
		</div>
<div class="row">	
 <div class="col-xs-4">
		<div class="panel panel-default">
   				<div class="panel-heading">
   				<div class="title" data-toggle="collapse">联系人名单</div>
				</div> 
			    <div class="list-group">
					<?php
					 $pdo=new PDO('mysql:dbname=p1;charset=utf8;','root');
					 @$text=$_REQUEST['text'];
					 $sqlstr='select * from p2';
					 if(!empty($text)){
					 	$sqlstr=$sqlstr." where name like '%".$text."%' or phone like '%".$text. "%'";
					 }
					 $sql=$pdo->prepare($sqlstr);
					 
					 $sql->execute();
					 $list=$sql->fetchAll(PDO::FETCH_NAMED);
					 foreach ($list as $val){
					 ?>
					 <div class="list-group-item" style="line-height:34px"><span class="glyphicon glyphicon-user"></span> <?php echo $val['name'];  
					  echo $val['phone']; echo $val['qq'];?><a class="btn btn-danger pull-right" href="delete.php?id=<?php echo $val['id']?>">删除</a></div>
					 <?php 
					 }
					?>
			</div> 
			</div>
			
			
			
			</div>
			</div>
			</div>
   </body>
